package com.ls.hnks.advice;

import com.ls.hnks.util.Result;
import com.ls.hnks.util.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Arrays;

@RestControllerAdvice
@Order(10087)
@Slf4j
public class GlobalExceptionHandler {
    // 全局异常拦截
    @ExceptionHandler
    public Result handlerException(Exception e) {
        log.error("异常信息：{}",e.getMessage());
        log.error("异常堆栈：{}",Arrays.toString(e.getStackTrace()));
        return Result.error(ResultCodeEnum.ERROR);
    }
}